<template>
	<view style="height: 100vh;background: #F5F6FA;padding-bottom: 200rpx;">
		<view class="header" :style="{'height':statusBarHeight+'px'}">
			<view class="navon" :style="{'height':statusBarHeight+'px','padding-top':statusBarHeight1+'px'}">
				<view class="header-back" @click="goBack()">
					<i class="iconfont" style="font-size: 20px;">&#xe605</i>
				</view>
				<view class="hearder-content">
					{{chatName}}
				</view>
			</view>
		</view>


		<view class="">
			<view class="content-bg" :style="{'top':statusBarHeight+'px'}">

				<!-- 定位 -->
				<view class="content-tab">
					<view class="" style="display: flex;align-items: center;">
						<image src="https://pw.qyang.cc/static/location1.png" mode=""></image>
						<view class="address">
							成都市金华万达广场澳洲牛排自助
						</view>
					</view>
					<view class="distance">
						相距1.2km
					</view>
				</view>

				<!-- 地图 -->
				<map style="width: 100%; height: 500rpx;" />
				<!-- 聊天 -->

				<view class="" style="margin-top: 20rpx;">
					<scroll-view :style="{height: `${windowHeight-inputHeight - 180}rpx`}" id="scrollview"
						scroll-y="true" :scroll-top="scrollTop" class="scroll-view">
						<!-- 聊天主体 -->
						<view id="msglistview" class="chat-body">
							<!-- 聊天记录 -->
							<view v-for="(item,index) in msgList" :key="index">
								<view class="chatTime">
									<view class="" style="margin-right: 10rpx;">
										{{item.dateTime}}
									</view>
									<view class="">
										{{item.time}}
									</view>
								</view>
								<!-- 自己发的消息 -->
								<view class="item self" v-if="item.userContent != ''">
									<!-- 文字内容 -->
									<view class="content right">
										{{item.userContent}}
									</view>
									<!-- 头像 -->
									<image style="width: 70rpx;height: 70rpx;" class="avatar" :src="item.image">
									</image>
								</view>
								<!-- 对方发的消息 -->
								<view class="item Ai" v-if="item.botContent != ''">
									<!-- 头像 -->
									<image style="width: 70rpx;height: 70rpx;" class="avatar" :src="item.image">
									</image>
									<!-- 文字内容 -->
									<view class="content left">
										{{item.botContent}}
									</view>
								</view>
							</view>
						</view>
					</scroll-view>
					<view class="chatBottom">
						<view class="">
							<input style="width: 480rpx;background-color: #fff;border: none;height: 60rpx;" />
						</view>
						<image src="https://pw.qyang.cc/static/smile.png" mode="" style="width: 60rpx;height: 60rpx;"></image>
						<image src="https://pw.qyang.cc/static/add.png" mode="" style="width: 60rpx;height: 60rpx;"></image>
					</view>

				</view>




			</view>
		</view>






	</view>
</template>

<script>
	import index from '../../uni_modules/uview-ui';

	export default {

		data() {
			return {
				chatName: '',
				statusBarHeight: 0,
				statusBarHeight1: 0,
				titleBarHeight:0,

				msgList: [{
						chatName: '王思聪',
						botContent: "你好啊",
						userContent: "",
						image: 'https://pw.qyang.cc/static/avator.png',
						dateTime: '2024-09-26',
						time: '11:45:40'
					},
					{
						botContent: "",
						userContent: "你好",
						image: 'https://pw.qyang.cc/static/avatar2.png',
						dateTime: '2024-09-26',
						time: '11:45:40'
					},
				]




			}
		},
		onLoad() {
			uni.getSystemInfo({
				success: (res) => {
					// #ifdef MP-WEIXIN
						this.statusBarHeight1 = uni.getMenuButtonBoundingClientRect().top;
						this.titleBarHeight = uni.getMenuButtonBoundingClientRect().height;
						this.statusBarHeight = this.titleBarHeight + this.statusBarHeight1;
					// #endif	
					// #ifndef MP-WEIXIN
						this.statusBarHeight = res.statusBarHeight * 1 + 46;
						this.statusBarHeight1 = res.statusBarHeight;
					// #endif
				},
			});	
			this.chatName = this.msgList[0].chatName
			console.log(this.msgList[0].chatName, 'this.msgList[0].chatName');
		},
		methods: {
			goBack() {
				console.log(111);
				uni.navigateBack()
			},
			selectTab(index) {
				console.log(111);
				this.selectedIndex = index;
			},


		}
	}
</script>

<style lang="scss" scoped>
	.chatTime {
		// text-align: center;
		color: rgb(76, 77, 81);
		font-size: 28rpx;
		display: flex;
		justify-content: center;
	}

	.chatBottom {
		position: fixed;
		bottom: 0;
		width: 100%;
		display: flex;
		justify-content: space-around;
		background-color: rgb(241, 241, 241);
		padding: 40rpx 0;
	}

	.Ai {
		display: flex;

		image {
			margin: 0 20rpx;
		}
	}

	.self {
		display: flex;
		justify-content: flex-end;
		margin: 20rpx;


		image {
			margin: 0 20rpx;
		}
	}

	.content {
		max-width: 500rpx;
	}

	.right {
		background-color: rgb(221, 233, 249);
		border: 2rpx solid rgb(191, 210, 242);
		// text-align: center;
		padding: 20rpx;
		font-size: 28rpx;

		border-radius: 20rpx 0 20rpx 20rpx;
	}

	.left {
		background-color: #fff;
		border: 2rpx solid rgb(219, 220, 220);
		// text-align: center;
		padding: 20rpx;
		font-size: 28rpx;
		border-radius: 0 20rpx 20rpx 20rpx;
	}

	.submitBtn {
		width: 700rpx;
		height: 74rpx;
		background: #FF5866;
		color: #fff;
		text-align: center;
		line-height: 71rpx;
		position: absolute;
		bottom: 600rpx;
		left: 27rpx;
		border-radius: 200rpx;
	}




	.content-bg {

		position: relative;
	}

	.content-tab {
		position: relative;
		display: flex;
		justify-content: space-between;
		height: 80rpx;
		line-height: 80rpx;
		background-color: #fff;
		padding: 20rpx;

		image {
			width: 24rpx;
			height: 28rpx;
			display: block;
			margin-right: 10rpx;
		}

		.address {
			font-family: 阿里巴巴普惠体 2.0;
			font-size: 26rpx;
			color: #333;
			font-weight: 400;
		}

		.distance {
			font-family: 阿里巴巴普惠体 2.0;
			font-size: 26rpx;
			color: #333;
			font-weight: 500;
		}

	}

	.header {
		width: 100%;
		height: auto;
		display: table;
		position: fixed;
		top: 0px;
		left: 0px;
		z-index: 10;
		background-color: #fff;

		.header-back {
			margin-left: 10rpx;
			height: 13px;
			line-height: 13px;
			position: absolute;
			left: 0;
			color: #000;
		}

		.hearder-content {
			font-size: 16px;
			font-weight: normal;
			line-height: 28px;
			text-align: center;
			display: flex;
			align-items: center;
			letter-spacing: 0px;
			color: #000;
		}

		.navon {
			width: 100%;
			height: auto;
			position: absolute;
			top: 0px;
			left: 0px;
			box-sizing: border-box;
			font-weight: 500;
			font-size: 36rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}

	}
</style>